#include <REGX52.H>

void delay_ms(unsigned int ms)
{
    unsigned int i, j;
    for (i = 0; i < ms; i++)
    {
        for (j = 0; j < 123; j++)
            ;
    }
}

void main()
{
    unsigned int a;
    while(1)
    {
        for (a=0;a<=7;a++)
        {
            P2 = ~(0x01<<a)
            delay_ms(500);
        }
        P2 = 0x00;
        delay_ms(500);
    }
}